﻿using System;

namespace UtilityToolsCollect.ObjectsLibrary.ProcessManage
{
    /// <summary>
    /// 进程管理调度基类
    /// </summary>
    public abstract class ProcesMangeScheduleAbstract:IDisposable
    {
        

        protected IProcessManage Manage { get; set; }
        public ProcesMangeScheduleAbstract(IProcessManage manage) { Manage = manage; }
        public abstract bool IsRunning { get; }
        public abstract void ScheduleNext();
        public abstract void Stop();
        public abstract void StartRunning();

        #region Dispose
        private bool disposedValue;
        protected abstract void OnDispose();
        protected virtual void _Dispose()
        {
            if (!disposedValue)
            {
                if (Manage != null)
                {
                    Manage = null!;
                }
                OnDispose();
                disposedValue = true;
            }
        }
        ~ProcesMangeScheduleAbstract() { _Dispose(); }
        public void Dispose() { _Dispose(); GC.SuppressFinalize(this); }
        #endregion
    }
}
